import { ElNotification } from "element-plus";
let errorFlag = false;
type TPosition = "top-right" | "top-left" | "bottom-right" | "bottom-left";

/**
 * 消息提示
 */
export function Notification(title: string, message: string, position: TPosition = "top-right", options?: { [key: string]: any }) {
  ElNotification({
    title,
    message,
    position,
    duration: 2000,
    ...options
  })
}

/**
 * 错误消息提示
 */
export function NotificationError(title: string, message: string, position: TPosition = "top-right") {
  if (errorFlag) return;
  errorFlag = true;
  Notification(title, message, position, { type: "error" })
  setTimeout(() => {
    errorFlag = false;
  }, 2000)
}